﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HFController;
namespace HFWebApp.news
{
    public partial class NewsList : BagePages
    {
        public string ListTitle = "全部法制资讯";
        public string PageStr = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int PageSize = 18;
                int PageNumber = 1;
                if (this.GetQuery("Page") != "")
                {
                    PageNumber = int.Parse(this.GetQuery("Page"));
                }
                int total = 0;

                string strWhere = "";

                #region 搜索条件
                string TopicID = this.GetQuery("topicid");
                string ClassID = this.GetQuery("classid");
                string bClassID = this.GetQuery("bclassid");
                string sClassID = this.GetQuery("sclassid");
                string keyword = this.GetQuery("keyword");

                if (TopicID != "")
                {
                    strWhere = "TopicID = " + TopicID;
                    ListTitle = NewsController.getController().getTopicClassModel(int.Parse(TopicID)).TopicName;
                }

                if (ClassID != "")
                {
                    if (strWhere == "")
                    {
                        strWhere = "ClassID = " + ClassID;
                        ListTitle = LegalAffairsController.getController().getLegalAffairsModel(int.Parse(ClassID)).LegalAffairsTitle;
                    }
                    else {
                        strWhere = strWhere + " and ClassID = " + ClassID;
                    }
                }

                if (bClassID != "")
                {
                    if (strWhere == "")
                    {
                        strWhere = "bClassID = " + bClassID;
                        ListTitle = LegalAffairsController.getController().getLegalAffairsBiglClassModel(int.Parse(bClassID)).ClassName;
                    }
                    else
                    {
                        strWhere = strWhere + " and bClassID = " + bClassID;
                    }
                }

                if (sClassID != "")
                {
                    if (strWhere == "")
                    {
                        strWhere = "sClassID = " + sClassID;
                        ListTitle = LegalAffairsController.getController().getLegalAffairsSmallClassModel(int.Parse(sClassID)).SmallClassName;
                    }
                    else
                    {
                        strWhere = strWhere + " and sClassID = " + sClassID;
                    }
                }

                if (keyword != "")
                {
                    if (strWhere == "")
                    {
                        ListTitle = "关键字搜索";
                        strWhere = "Title  like '%" + keyword + "%' ";
                    }
                    else {
                        strWhere = strWhere + " and Title  like '%" + keyword + "%' ";
                    }
                }
                #endregion

                Repeater1.DataSource = NewsController.getController().getNewsList(PageSize, PageNumber, strWhere, out total);
                Repeater1.DataBind();
                PageStr = LLL.Pager.TrunPageHtmlCode_Web(PageSize, PageNumber, total, "");
            }
        }
    }
}